package com.house.java.util;

import java.sql.Date;

import com.house.java.model.NewHouse;

public class NewHouseUtils {

	public void setNewHouse(NewHouse house,String fieldName,String fieldValue){
		if(StringUtils.hasLength(fieldValue) && StringUtils.hasLength(fieldName)){
			setFieldForNewHouse(house, fieldName, fieldValue);
		}
	}
	
	/**
	 * 根据属性名设置NewHouse的属性值
	 * @param house
	 */
	public void setFieldForNewHouse(NewHouse house,String fieldName,String fieldValue){
		if(fieldName.equals("name")){
			house.setName(fieldValue);
		}else if (fieldName.equals("id")) {
			house.setId(Long.valueOf(fieldValue));
		}else if (fieldName.equals("wuyeCategory")) {
			house.setWuyeCategory(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("projectTrait")) {
			house.setProjectTrait(fieldValue);
		}else if (fieldName.equals("jianzhuCategory")) {
			house.setJianzhuCategory(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("zhuangxiuLocation")) {
			house.setZhuangxiuLocation(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("location")) {
			house.setLocation(fieldValue);
		}else if (fieldName.equals("locationCountryCode")) {
			house.setLocationCountryCode(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("locationProvinceCode")) {
			house.setLocationProvinceCode(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("locationCityCode")) {
			house.setLocationCityCode(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("locationDistrict")) {
			house.setLocationDistrict(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("greenRate")) {
			house.setGreenRate(Double.parseDouble(fieldValue));
		}else if (fieldName.equals("openTime")) {
			house.setOpenTime(Date.valueOf(fieldValue));
		}else if (fieldName.equals("completionTime")) {
			house.setCompletionTime(Date.valueOf(fieldValue));
		}else if (fieldName.equals("wuyeCharge")) {
			house.setWuyeCharge(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("wuyeCompany")) {
			house.setWuyeCompany(fieldValue);
		}else if (fieldName.equals("developers")) {
			house.setDevelopers(fieldValue);
		}else if (fieldName.equals("licence")) {
			house.setLicence(fieldValue);
		}else if (fieldName.equals("sellLocation")) {
			house.setSellLocation(fieldValue);
		}else if (fieldName.equals("wuyeLocation")) {
			house.setWuyeLocation(fieldValue);
		}else if (fieldName.equals("traffic")) {
			house.setTraffic(fieldValue);
		}else if (fieldName.equals("price")) {
			house.setPrice(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("loucengDesc")) {
			house.setLoucengDesc(fieldValue);
		}else if (fieldName.equals("carPortCount")) {
			house.setCarPortCount(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("proDesc")) {
			house.setProDesc(fieldValue);
		}else if (fieldName.equals("zhandiAcreage")) {
			house.setZhandiAcreage(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("jianzhuAcreage")) {
			house.setJianzhuAcreage(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("beginTime")) {
			house.setBeginTime(Date.valueOf(fieldValue));
		}else if (fieldName.equals("overTime")) {
			house.setOverTime(Date.valueOf(fieldValue));
		}else if (fieldName.equals("investor")) {
			house.setInvestor(fieldValue);
		}else if (fieldName.equals("anjieBank")) {
			house.setAnjieBank(fieldValue);
		}else if (fieldName.equals("chanquanNianxian")) {
			house.setChanquanNianxian(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("houseHolds")) {
			house.setHouseHolds(Integer.parseInt(fieldValue));
		}else if (fieldName.equals("images")) {
			fieldValue = StringUtils.hasLength(house.getImages())?(house.getImages()+StringUtils.semicolon+fieldValue):fieldValue;
			house.setImages(fieldValue);
		}
	}
}
